// 设置
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:sz/tools/tools.dart';

class SetPage extends StatefulWidget {
  const SetPage({Key? key}) : super(key: key);

  @override
  State<SetPage> createState() => _SetPageState();
}

class _SetPageState extends State<SetPage> {
  List<Map<String, dynamic>> listOne = [
    {'title': '关于首筑', 'url': 'mineSet/about'},
    {'title': '检测更新', 'url': ''},
    {'title': '在线客服', 'url': ''},
  ];
  List<Map<String, dynamic>> listTwo = [
    {'title': '账户与安全', 'url': 'mineSet/safet'},
  ];
  List<Map<String, dynamic>> listThree = [
    {'title': '隐私设置', 'url': ''},
  ];
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: SzColor.f4f4f4,
      appBar: buildAppBar(),
      body: Column(
        children: [
          Expanded(
            child: CustomScrollView(
              slivers: [
                buildItem(listOne),
                buildItem(listTwo),
                buildItem(listThree),
              ],
            ),
          ),
          Container(
              width: rpx(750),
              height: rpx(120),
              alignment: Alignment.center,
              decoration: const BoxDecoration(color: Colors.white),
              child: ElevatedButton(
                style: ButtonStyle(
                  backgroundColor:
                      MaterialStateProperty.all(SzColor.primary), //背景颜色
                  foregroundColor:
                      MaterialStateProperty.all(Colors.white), //文字颜色
                  shape: MaterialStateProperty.all(
                    //圆角
                    RoundedRectangleBorder(
                      borderRadius: BorderRadius.circular(
                        rpx(10),
                      ),
                    ),
                  ),
                  fixedSize: MaterialStateProperty.all(
                    //大小
                    Size(rpx(660), rpx(80)),
                  ),
                ),
                onPressed: () {
                  Get.toNamed('login');
                },
                child: const Text("退出登录"),
              ))
        ],
      ),
    );
  }

  AppBar buildAppBar() {
    return AppBar(
      title: const Text(
        '设置',
        style: TextStyle(color: Colors.white),
      ),
      backgroundColor: SzColor.primary,
      centerTitle: true,
      leading: IconButton(
        onPressed: () {
          Get.back();
        },
        icon: Icon(
          Icons.chevron_left,
          color: Colors.white,
          size: setSp(60),
        ),
      ),
    );
  }

  SliverList buildItem(List<Map<String, dynamic>> listData) {
    return SliverList(
      delegate: SliverChildBuilderDelegate((BuildContext context, int index) {
        return Container(
          margin: EdgeInsets.only(
            top: index > 0 ? rpx(0) : rpx(24),
          ),
          decoration: const BoxDecoration(
            color: Colors.white,
          ),
          child: InkWell(
            onTap: () {
              FPrint('e12');
              if (listData[index]['url'].length > 0) {
                Get.toNamed(listData[index]['url']);
              } else {
                SzEasyLoading.showToast('暂无开启');
              }
            },
            child: Container(
              margin: EdgeInsets.symmetric(horizontal: rpx(40)),
              padding: EdgeInsets.symmetric(vertical: rpx(30)),
              decoration: BoxDecoration(
                border: Border(
                  bottom: BorderSide(
                    width: listData.length - 1 != index ? rpx(2) : 0,
                    color: SzColor.f4f4f4,
                  ),
                ),
              ),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Text(listData[index]['title']),
                  Icon(
                    AliIcon.qingxuanzeyoujiantou,
                    color: const Color(0xffC8C8C8),
                    size: setSp(28),
                  )
                ],
              ),
            ),
          ),
        );
      }, childCount: listData.length),
    );
  }
}
